<template>

    <div class="page-100 task-layout">
        <div class="tab-part">
            <TabsComponent
                    :tabs="tabsOne"
                    :current="tabIndex"
                    v-on:tab-switch="switchHandler"/>
        </div>
        <!--一个按钮的时候-->
        <div class="button-backgrond" v-if="isshowButton">
            <yd-button  size="large" type="primary" @click.native="confrimClick" style="background-color:#3cc8a8;color:white">{{buttonName}}
            </yd-button>
        </div>
        <!-- 路由出口 -->
        <!-- 路由匹配到的组件将渲染在这里 -->
        <router-view></router-view>
    </div>

</template>

<script>
    import {voucherapplyDetails} from "../../pcof/post";
    import {userInfoData,qn_domain} from '../../globalVariables'
    import TabsComponent from "@/components/TabsComponent.vue";
    export default {
        name: "voucherDetailandProgress",
        data() {
            return {
                applicationUuid: '',
                buttonName:'',
                state:'',
                type:'',
                isshowButton:false,//一个按钮
                dataList:[],
                state:'',
                dataList:[],
                tabsOne: [
                    {id: 1, text: "详情"},
                    {id: 2, text: "进度"},
                ],
                tabIndex: 1,

            }

        },
        methods:
            {
                switchHandler(payload) {
                    console.log(payload.index);
                    if (payload.index === 0) {
                        this.$router.replace({name: 'voucherDetail', params: {applicationUuid: this.applicationUuid}});
                    } else if (payload.index === 1) {
                        this.$router.replace({name: 'voucherProgress', params: {applicationUuid: this.applicationUuid,type:this.type}});
                    }
                },
                confrimClick()
                {
                    console.log(this.state);
                    if (this.state==='03')
                    {
                        //确认收货
                        this.$router.replace({name: 'voucherShouhuonum', params: {applicationUuid: this.applicationUuid,dataAr:this.dataList,type:'2'}});


                    }else if (this.state==='95')
                    {
                        //评价';
                        this.$router.replace({name: 'customEvaluate', params: {type: '2',uuid: this.applicationUuid}});//type //1 是办公用品 2是凭证请领

                    }else
                    {
                        this.isshowButton=false;

                    }
                }
            },
       async created()
        {
            this.applicationUuid =  this.$route.params.applicationUuid;
            this.state=this.$route.params.state;
            this.type=this.$route.params.type;

            var mobile = JSON.parse(localStorage.getItem(userInfoData)).mobile;
            console.log(this.applicationUuid);
            this.$dialog.loading.open('加载中...');

            var response = await voucherapplyDetails(mobile,this.applicationUuid);
            if (response.data.code === 200) {
                this.$dialog.loading.close();
                this.dataList=response.data.data.vouchers;

            }else
            {
                this.$dialog.loading.close();
                this.$dialog.toast({
                    mes: response.data.msg,
                    timeout: 1500
                });
            }

            //type 0是待办页 1是历史页来的(不显示button)
            //  ("00", "待审批"),("01", "审批中"),("02", "待配送"),("03", "配送中"),("85", "已撤销"),("90", "被拒绝"),("95", "待评价"),("99", "已完成");

            if (this.type === '0') {
                if (this.state==='03')
                {
                    this.buttonName='确认收货';
                    this.isshowButton=true;
                }else if (this.state==='95')
                {
                    this.buttonName='评价';
                    this.isshowButton=true;

                }else
                {
                    this.isshowButton=false;

                }
            }else
            {
                this.isshowButton=false;

            }
            this.$router.replace({name: 'voucherDetail', params: {applicationUuid: this.applicationUuid}});


        },
        components: {

            TabsComponent,
        },
    }
</script>

<style lang="scss">
    /*导航栏浮动设置*/
    /*.task-layout {*/
        /*导航栏浮动设置*/
        /*.tab-part {*/
        /**/
            /*z-index:200;*/
            /*position: fixed;*/
            /*width: 100%;*/
            /*height: 1rem;*/
            /*top: 0;*/
            /*left: 0;*/
        /*}*/
    /*}*/

    .button-backgrond
    {
        position: fixed;
        bottom: 0px;
        left: 0;
        width: 100%;
        background-color: #f9f9f9;
        z-index: 3000;
    }
</style>